package com.xiaobai.wechat.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;

/**
 * @author feng
 */
public class JsoupUtil {
    public static String getIpAddress(String ip) {
        String address = "北京";
        try {
            Document connect = Jsoup.connect("https://www.ip.cn/ip/" + ip + ".html").get();
            Element tab0Address = connect.getElementById("tab0_address");
            if (tab0Address != null) {
                address = tab0Address.text();
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return address;
    }
}
